package com.kuiandjie.web;


import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.kuiandjie.entity.Document;
import com.kuiandjie.entity.Project;
import com.kuiandjie.service.DocumentService;

public class DucumentServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		HttpSession session = request.getSession();
		
		Project curp = (Project) session.getAttribute("curp");
		if(curp.getId() == 0){
			response.sendError(403);
			
		}else{
			DocumentService ds = new DocumentService();

			List<Document> documentlist =  ds.findAllDocumentByProId(curp.getId());

				request.setAttribute("documentlist", documentlist);
				request.getRequestDispatcher("WEB-INF/views/document.jsp").forward(request, response);
		
		
			
		}
		
	}
	
	

}
